import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/black-crystal',
      name: 'black-crystal',
      // 路由懒加载
      component: () => import('../views/black-crystal.vue')
    },
    {
      path: '/brand',
      name: 'brand',
      component: () => import('../views/brand.vue')
    }
  ],
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  }
})

export default router 